//
//  PJMDispatch.swift
//  PJMProFramework
//
//  Created by hui wang on 2024/12/2.
//

import UIKit

public enum PJMDispatch {
    public static func onMain(_ work: @escaping @convention(block) () -> Void) {
        if Thread.isMainThread {
            work()
        } else {
            DispatchQueue.main.async(execute: work)
        }
    }
    
    public static func onMainQueue(_ work: @escaping @convention(block) () -> Void, after: TimeInterval) {
        DispatchQueue.main.asyncAfter(deadline: .now() + after) {
            work()
        }
    }
    
    public static func runOnHighPriorityQueue(_ work: @escaping @convention(block) () -> Void) {
        DispatchQueue.global(qos: .userInitiated).async(execute: work)
    }
}
